algorithm to check eligibility for voting